package com.iptv.grape.util;

import android.util.Log;

import com.iptv.grape.RunTimeApplication;

//import static androidx.constraintlayout.widget.Constraints.TAG;

public class AppLog {
    public static final String TAG = "Grape";
    private static AppLog curLog = null;
    private static boolean isDebug = false;

    public static AppLog getCurLog(){
        if(curLog == null){
            synchronized (AppLog.class){
                curLog = new AppLog();
            }
        }
        return curLog;
    }
    private AppLog(){
        isDebug = RunTimeApplication.getCurApp().isDebug();
    }

    public void out(String text){
        if(isDebug){
            //System.out.println(text);
            Log.d(TAG, text);
        }
    }

    public void out(boolean val){
        if(isDebug){
            //System.out.println(val);
            Log.d(TAG, val + "");
        }
    }

    public void out(int val){
        if(isDebug){
            Log.d(TAG, val + "");
        }
    }

    public void out(long val){
        if(isDebug){
            Log.d(TAG, val + "");
        }
    }

    public void e(Object... objs){
        StringBuilder stringBuilder = new StringBuilder();
        for (Object obj:objs){
            if(null == obj)
                continue;
            stringBuilder.append(obj);
        }
        if(isDebug){
            Log.e(TAG, stringBuilder.toString());
        }
    }
    public void net(Object... objs){
        StringBuilder stringBuilder = new StringBuilder();
        for (Object obj:objs){
            if(null == obj)
                continue;
            stringBuilder.append(obj);
        }
        if(isDebug){
            Log.e(TAG+"_NET", stringBuilder.toString());
        }
    }
    public void d(Object... objs){
        StringBuilder stringBuilder = new StringBuilder();
        for (Object obj:objs){
            if(null == obj)
                continue;
            stringBuilder.append(obj);
        }
        if(isDebug){
            Log.d(TAG, stringBuilder.toString());
        }
    }
}
